package com.tdt.alarm.model;

import android.app.Activity;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ArrayAdapter;
import android.widget.TextView;

import com.tdt.alarm.R;

public class DateTimeAdapter extends ArrayAdapter<String> {

	Activity context = null;
	String[] items;
	int layoutId;

	public DateTimeAdapter(Activity context, int layoutId, String[] items) {
		super(context, layoutId, items);
		this.context = context;
		this.layoutId = layoutId;
		this.items = items;
	}

	@Override
	public View getView(int position, View convertView, ViewGroup parent) {

		LayoutInflater inflater = context.getLayoutInflater();
		convertView = inflater.inflate(layoutId, null);
		if (position == 0 || position == 4) {
			convertView = inflater.inflate(R.layout.row_two, null);
			TextView tv = (TextView) convertView
					.findViewById(R.id.textViewSetting2);
			TextView tvDetail = (TextView) convertView
					.findViewById(R.id.textViewSettingDetail2);
			tv.setText(items[position]);
			tvDetail.setText(items[position]);
		} else {
			TextView tv = (TextView) convertView
					.findViewById(R.id.textViewSetting1);
			TextView tvDetail = (TextView) convertView
					.findViewById(R.id.textViewSettingDetail1);
			tv.setText(items[position]);
			tvDetail.setText(items[position]);
		}

		return convertView;
	}

}
